//
//  ZLLDiskCache.h
//  Test
//
//  Created by Vincent on 2017/2/13.
//  Copyright © 2017年 Vincent. All rights reserved.
//

/**
 *该类为磁盘缓存类
 *实现对象缓存、获取缓存对象、删除缓存对象
 *
 */

#import <Foundation/Foundation.h>


typedef void (^ZLLDiskCacheBlock)(NSString *key,id<NSCoding> object,NSURL *fileURL,NSError *error);


@interface ZLLDiskCache : NSObject



/**缓存对象
 *@param    rootObject      缓存的对象
 *@param    key             缓存的键值
 *@param    path            缓存的路径
 *@param    block           缓存完成的回调
 *
 */
+(void)cacheObject:(id<NSCoding>)rootObject forKey:(NSString *)key atPath:(NSString *)path completionBlock:(ZLLDiskCacheBlock)block;


/**获取缓存对象
 *@param    key             缓存的键值
 *@param    path            缓存的路径
 *@param    block           获取缓存对象后的回调
 *
 */
+(void)objectForKey:(NSString *)key atPath:(NSString *)path completionBlock:(ZLLDiskCacheBlock)block;



/**删除缓存对象(dispatch_barrier_async实现）
 *@param    key             缓存的键值
 *@param    path            缓存的路径
 *@param    block           删除缓存对象后的回调
 *
 */
+(void)removeObjectForKey:(NSString *)key atPath:(NSString *)path completionBlock:(ZLLDiskCacheBlock)block;


@end
